// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asMeshComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the MeshComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asMeshComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"


//! Reference factory for the MeshComponent class.
MeshComponent* createMeshComponent(Entity *parent)
{
    return new MeshComponent(parent);
}

//! Reference factory for the MeshComponent class.
MeshComponent* createMeshComponent(Entity *parent, const std::string &fileName,
                                   const vector3df &scale)
{
    return new MeshComponent(parent, fileName, scale);
}

//! Binds the MeshComponent class to AngelScript.
void bindMeshComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind MeshComponent class.
    r = engine->RegisterObjectType("MeshComponent", sizeof(MeshComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindMeshComponentBase<MeshComponent>(engine, "MeshComponent");

    // Set MeshComponent behaviour.
    r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @+)",
                                        asFUNCTIONPR(createMeshComponent, (Entity*), MeshComponent*), asCALL_CDECL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @+, const string &in, " \
                                        "const vector3df &in)", asFUNCTIONPR(createMeshComponent, (Entity*, const std::string&,
                                        const vector3df&), MeshComponent*), asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("MeshComponent", "MeshComponent& opAssign(const MeshComponent &in)",
                                     asFUNCTION(assignT<MeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
